<!<!DOCTYPE>
<html>
    <head>
        <meta charset="utf-8" />
        <title>客户端地址汇总-金装</title>
        <link rel="stylesheet" href="main.css"  type="text/css" />
        <script src="config.js">
        </script>
        <script>
            function goto_web(evt)
            {
                var nameSlt = document.getElementById("nameSelect")
                var slt =document.getElementById("prjSelect")
                var peopleObj = config[nameSlt.selectedIndex]
                var obj = peopleObj.data[slt.selectedIndex]
                var url = "http://"+peopleObj.ip+":"+obj.port+obj.path           
                url = "http://www.baidu.com"     
                window.location.href = url
                
                //var doc = window.open("http://www.baidu.com")
                console.log(url+doc.document.title)
            }
            function onBodyLoad()
            {
                var slt =document.getElementById("nameSelect")
                slt.options.length = 0 //删除所有
                for(var i= 0;i<config.length;i++)
                {
                    var obj = config[i]
                    var opt = new Option(obj.name,i+1)
                    i==0?opt.selected = true:""; 
                    slt.add(opt)
                }
                
                onSelectName()
            }
            function onSelectName()
            {
                var slt =document.getElementById("nameSelect")                
               
                var data = config[slt.selectedIndex].data
                slt =document.getElementById("prjSelect")
                slt.options.length = 0 //删除所有
                for(var i = 0;i<data.length;i++)
                {
                    var obj =data[i]
                    var opt = new Option(obj.text,i+1)
                    i==0?opt.selected = true:""; 
                    console.log("opt.selected:"+opt.selected+":"+opt.value)
                    slt.add(opt)
                }

                //alert("onSelectName slt.selectedIndex:"+slt.selectedIndex)
            }

        </script>
    </head>
    <body onload="onBodyLoad()">
        <div class="main">
            <h1>项目地址：</h1>
            <select id="nameSelect" class="selectStyle" onchange="onSelectName()">

            </select>
            <select id="prjSelect" onchange="" >     
                <option>哈哈</option>                         
                <option>呵呵</option>                         
                <option>嘻嘻</option>                         
            </select>
            <button onclick="goto_web(this)">前往</button>
        </div>
        
    </body>
</html>